package com.example.homework07.service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.homework07.R;

public class startservice extends Fragment {
    public startservice() {
        super(R.layout.startservice);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getView().findViewById(R.id.stbf).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        getActivity().startService(new Intent(getActivity(),
                                MusicService.class));
                    }
                }
        );
        getView().findViewById(R.id.sttz).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        getActivity().stopService(new Intent(getActivity(),
                                MusicService.class));
                    }
                }
        );
    }
}
